//
// Created by 下次一定 on 2021/9/6.
//单调队列
//


#include<iostream>

using namespace std;

const int N = 100010;

int n, k;
int a[N], q[N];

int main() {
    cin.tie(0);
    cin >> n >> k;

    for (int i = 0; i < n; i++) cin >> a[i];

    int hh = 0, tt = -1;

    for (int i = 0; i < n; i++) {
        //队头是否滑出窗口
        if (hh <= tt && i - k + 1 > q[hh]) hh++;

        while (hh <= tt && a[q[tt]] >= a[i]) tt--;
        q[++tt] = i;
        if (i >= k - 1)cout << a[q[hh]] << " ";
    }

}

